package cn.tedu.rms.reservation.controller;

import cn.tedu.rms.base.response.JsonResult;
import cn.tedu.rms.reservation.pojo.dto.ReservationQuery;
import cn.tedu.rms.reservation.pojo.dto.ReservationSaveParam;
import cn.tedu.rms.reservation.pojo.vo.ReservationVO;
import cn.tedu.rms.reservation.service.ReservationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@Api(tags = "预约模块")
@RestController
@RequestMapping("/v1/reservation")
public class ResrvationController {

    @Autowired
    ReservationService reservationService;
    @ApiOperation("查询预约")
    @GetMapping("/select")
    public JsonResult select(ReservationQuery reservationQuery){
        log.debug("查询预约:参数={}",reservationQuery);
        List<ReservationVO> list=reservationService.selectReservation(reservationQuery);
        return JsonResult.ok(list);
    }

    @ApiOperation("保存预约,(修改或新增)")
    @PostMapping("/save")
    public JsonResult save(ReservationSaveParam reservationSaveParam){
        log.debug("保存预约:参数={}",reservationSaveParam);
        reservationService.save(reservationSaveParam);
        return JsonResult.ok();
    }
    @ApiOperation("删除预约")
    @PostMapping("/delete/{id}")
    public JsonResult delete(@PathVariable Long id){
        log.debug("删除预约:参数={}",id);
        reservationService.delete(id);
        return JsonResult.ok();
    }
}
